package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.ysd.entity.About;
import com.ysd.util.DBManage;

public class AboutDao {

	public ArrayList<About> getAllAbout(){
		ArrayList<About> ab=new ArrayList<About>();
		try {
			Connection conn=DBManage.getConn();
			Statement stam=conn.createStatement();
			ResultSet rs=stam.executeQuery("select title,english,imgUrl from aboutInfo");
			while(rs.next()) {
				About result=new About(rs.getString("title"),rs.getString("english"),rs.getString("imgUrl"));
				ab.add(result);
			}
			DBManage.colseAll(rs, stam, conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return ab;
	}
	public About getAbout() {
		About a=null;
		try {
			Connection conn=DBManage.getConn();
			Statement stam=conn.createStatement();
			ResultSet rs=stam.executeQuery("select * from aboutInfo limit 0,1");
			while(rs.next()) {
				a=new About(rs.getInt("id"),rs.getString("aboutImg"),rs.getString("aboutBrief"),rs.getString("aboutculture")
						,rs.getString("title"),rs.getString("english"),rs.getString("imgUrl"),rs.getString("advertising"),rs.getString("advertisingImg"));
			}
			DBManage.colseAll(rs, stam, conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return a;
	}
}
